/*
 * readBuffer.h
 *
 *  Created on: 2012. 4. 16.
 *      Author: jphong
 */

#ifndef READBUFFER_H_
#define READBUFFER_H_

#include	<sys/types.h>

typedef struct {
	int count;
	int rear;
	int front;
	char *buf;
	int bufsize;
} ReadBuffer;

ReadBuffer * createRbuf(ssize_t bufsize);
void destroyRbuf(ReadBuffer *rbuf);
void initRbuf(ReadBuffer *rbuf);
ssize_t readBuf(ReadBuffer *rbuf, int fd);
unsigned char getChar(ReadBuffer *rbuf);
unsigned char ungetChar(ReadBuffer *rbuf, unsigned char c);
ssize_t getString(ReadBuffer *rbuf, char *str, ssize_t len);
ssize_t getSuffix(ReadBuffer *rbuf, char *buf, ssize_t bufsize, char *suffix);
ssize_t getLine(ReadBuffer *rbuf, char *buf, ssize_t bufsize);
ssize_t getCRLF(ReadBuffer *rbuf, char *buf, ssize_t bufsize);
ssize_t getMessage(ReadBuffer *rbuf, char *buf, ssize_t bufsize);

#endif /* READBUFFER_H_ */
